package com.itic.mall.mobile.shenghe;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.itic.appbase.framework.utils.StringHelper;
import com.itic.mall.mobile.base.BaseMobileInterface;


/**
 * 友惠家商城中心接口类
 * @author 许小宝
 * 2017年07月25日  14时11分
 */
@Controller
@RequestMapping(value="/mobile/shenghe")
public class MallShengheInterface
     extends BaseMobileInterface {
	
    /**
     * APP折扣商城中心
     * @param categoryId 类别ID
     * @param orderType 排序类型
     * @param minMaxPrice 最小到最大的价格区间，中间用-号相隔
     * @param minMaxPrice 最小到最大的销量区间     中间用-号相隔
     * @return
     */
    @RequestMapping(value="/vip")
    @ResponseBody
    public Map<String,Object> index(HttpServletRequest request,HttpServletResponse response ){
    	Map<String, Object> resultMap = new HashMap<String,Object>();
    	String result = FAIL;
    	String errorCode = PARAM_ERROR_CODE;
    	String errorMsg = PARAM_ERROR_MSG;
    	try{
    		String isShow = sysSettingService.getByKey("VIP_IS_SHOW");
        	resultMap.put(DATA, isShow);
			result = SUCCESS;
			errorCode = SUCCESS_ERROR_CODE;
        	errorMsg = SUCCESS_ERROR_MSG;  	
        	
    	}catch(Exception e){
    		errorCode = SERVER_ERROR_CODE;
        	errorMsg = SERVER_ERROR_MSG;
        	//log(e);
        	logException("MallProductInterface", "index", e.toString(),"折扣商城中心商品列表",e);
    		
    	}
    	resultMap.put(RESULT, result);
    	resultMap.put(ERROR_CODE, errorCode);
    	resultMap.put(ERROR_MSG, errorMsg);
    	isCrrossDomain(response);
    	return resultMap;
    }
    
    /**
     * APP折扣商城中心
     * @param categoryId 类别ID
     * @param orderType 排序类型
     * @param minMaxPrice 最小到最大的价格区间，中间用-号相隔
     * @param minMaxPrice 最小到最大的销量区间     中间用-号相隔
     * @return
     */
    @RequestMapping(value="/yun")
    @ResponseBody
    public Map<String,Object> yun(HttpServletRequest request,HttpServletResponse response ,String version ){
    	Map<String, Object> resultMap = new HashMap<String,Object>();
    	String result = FAIL;
    	String errorCode = PARAM_ERROR_CODE;
    	String errorMsg = PARAM_ERROR_MSG;
    	try{
    		String isShow = "show";
    		
    		if( StringHelper.isNotBlank(version) ){
    			isShow = sysSettingService.getByKey(version);
    		}
        	resultMap.put(DATA, isShow);
			result = SUCCESS;
			errorCode = SUCCESS_ERROR_CODE;
        	errorMsg = SUCCESS_ERROR_MSG;  	
        	
    	}catch(Exception e){
    		errorCode = SERVER_ERROR_CODE;
        	errorMsg = SERVER_ERROR_MSG;
        	//log(e);
        	logException("MallProductInterface", "index", e.toString(),"折扣商城中心商品列表",e);
    		
    	}
    	resultMap.put(RESULT, result);
    	resultMap.put(ERROR_CODE, errorCode);
    	resultMap.put(ERROR_MSG, errorMsg);
    	isCrrossDomain(response);
    	return resultMap;
    }
    
}